#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
// priority_queue<int, vector<int>, less<int>> pq;

void solve() {
    int n, x;
    cin >> n >> x;
    int t = 0, p = 0;
    for(int i = 0; i < n; i++) {
        t |= i;
        if(i == n - 1 && t != x) break; 
        if((x | i) > x) break;
        p++;
        cout << i << ' ';
    }
    while(p < n){
        cout << x << ' ';
        p++;
    }
    cout << endl;

}

signed main() {
    int t; cin >> t;
    while(t--) solve();
    return 0;
}